﻿package util.idgenerator;

//主键ID生成工具类
public class IDGeneratorUtil {

	private static LongIDGeneratorFactory longIdGenerator = new LongIDGeneratorFactory();

	private static StringIDGeneratorFactory stringIdGenerator = new StringIDGeneratorFactory();

	//根据类型生成ID
	public static Object generate(char type) {
		switch (type) {
			case 's':
				return generateStringID();
			default:
				return generateLongID();
		}
	}

	//生成字符串ID
	public static String generateStringID() {
		return stringIdGenerator.generateID();
	}

	//生成长整型ID
	public static Long generateLongID() {
		return longIdGenerator.generateID();
	}

	public static void main(String[] args) {
		System.out.println(IDGeneratorUtil.generateStringID());
		System.out.println(IDGeneratorUtil.generateLongID());
	}

}
